#include <iostream>
#include <exception>
using namespace std;
struct MyException: public exception{
    // what()是由异常类提供的公共方法
    const char *what() const throw(){
        return "C++ exception";
    }
};
int main(){
    try{
        throw MyException();
    }catch(MyException& e){
        // std::exception 所有标准C++异常的异常和父类。
        cout << "MyException caught" << endl;
        cout << e.what() << endl;
    }catch(std::exception& e){
        // other errors
    }
}
